package com.campus_assistant.service.db1;

import com.alibaba.fastjson.JSON;
import com.campus_assistant.mapper.db1.StudentMapper;
import com.campus_assistant.pojo.db1.Student;
import com.campus_assistant.service.elasticsearch.ElasticSearchService;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.MatchAllQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.TermQueryBuilder;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private RestHighLevelClient restHighLevelClient;
    @Override
    public int addStu_info(Student stu_info) {

        return studentMapper.addStu_info(stu_info);
    }

    @Override
    public int deleteStu_infoById(int sId) {

        return studentMapper.deleteStu_infoById(sId);
    }

    @Override
    public int updateStu_info(Student stu_info) {

        return studentMapper.updateStu_info(stu_info);
    }
    //查询所有学生
    @Override
    public List<Student> getStu_infoListAll() {
        return studentMapper.getStu_infoListAll();
    }

    @Override
    public List<Student> getStudentPaginate(int pageNum, int pageSize) {
        return studentMapper.getStudentPaginate(pageNum,pageSize);
    }

    @Override
    public Student getStu_infoById(int sId) {
        return studentMapper.getStu_infoById(sId);
    }
    //根据姓名查询学生
    @Override
    public List<Student> getStu_infoListByName(String sName) {
        return studentMapper.getStu_infoListByName(sName);
    }

    @Override
    public Student getStudentByNum(String sNum) {
        return studentMapper.getStudentByNum(sNum);
    }

    @Override
    public int getIdByName(String sName) {
        return studentMapper.getIdByName(sName);
    }

    @Override
    public int getTotal() {
        return studentMapper.getTotal();
    }

    @Override
    public int resetsId() {
        return studentMapper.resetsId();
    }

    @Override
    public int selectStudentId(String sNum) {
        return studentMapper.selectStudentId(sNum);
    }


}

